/*
 * XML Parser class for the Concepts XML
 * */
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Attr;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

public class ConceptNameXMLParser {
	//Concepts will be stored in this list.
	static List conceptNameList = new ArrayList();
	public static String domainName;

	public ConceptNameXMLParser() {

	}

	public static void parseXML(File xmlFileToOpen)
			throws ParserConfigurationException, SAXException, IOException {
		DocumentBuilderFactory docFactory = DocumentBuilderFactory
				.newInstance();
		DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
		org.w3c.dom.Document doc = docBuilder.parse(xmlFileToOpen);
		listChildren(doc);
	}

	

	private static void listChildren(org.w3c.dom.Document doc) {

		// TODO Auto-generated method stub
		NodeList nodeList = doc.getElementsByTagName("Concept");
		int length = nodeList.getLength();

		for (int i = 0; i < length; i++) {
			NamedNodeMap nodemap = nodeList.item(i).getAttributes();
			conceptNameList.add(nodemap.item(0).getNodeValue());
		}

		NodeList node = doc.getElementsByTagName("Concepts");
		NamedNodeMap nodeMap = node.item(0).getAttributes();
		domainName = nodeMap.item(0).getNodeValue();

	}

}
